var e = require;
var t = module;
var o = exports;
var n,
    i = o,
    a =
        ((n = function (e, t) {
            return (n =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
                })(e, t);
        }),
        function (e, t) {
            function o() {
                this.constructor = e;
            }
            n(e, t), (e.prototype = null === t ? Object.create(t) : ((o.prototype = t.prototype), new o()));
        }),
    r = function (e, t, o, n) {
        var i,
            a = arguments.length,
            r = a < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, o)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(e, t, o, n);
        else
            for (var s = e.length - 1; s >= 0; s--)
                (i = e[s]) && (r = (a < 3 ? i(r) : a > 3 ? i(t, o, r) : i(t, o)) || r);
        return a > 3 && r && Object.defineProperty(t, o, r), r;
    };
Object.defineProperty(i, "__esModule", {value: !0});
var s = e("AssetsMap"),
    c = e("Util"),
    l = e("ShopSkinViewMediator"),
    d = cc._decorator,
    u = d.ccclass,
    p = d.property,
    h = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.itemImg = null),
                (t.itemName = null),
                (t.adBtn = null),
                (t.usedBtn = null),
                (t.decoratedBtn = null),
                (t.isInited = !1),
                (t.config = null),
                (t.otherinfo = null),
                (t.currentSnakeDeco = !1),
                t
            );
        }
        return (
            a(t, e),
            (t.prototype.review = function (e, t, o) {
                (this.config = e),
                    (this.otherinfo = t),
                    (this.currentSnakeDeco = o),
                    this.isInited || ((this.isInited = !0), this.addEvent()),
                    this.renderItem();
            }),
            (t.prototype.renderItem = function () {
                if (
                    ((this.itemImg.spriteFrame = c.default.getGameBundleSpriteFrame(
                        s.default.GameBundle.textures.assetsList["decorate_icon_" + this.config.index]
                    )),
                    (this.itemName.string = this.config.chinese),
                    (this.adBtn.active = !1),
                    (this.usedBtn.active = !1),
                    (this.decoratedBtn.active = !1),
                    !this.otherinfo.isUnlock)
                )
                    return (
                        (this.adBtn.active = !0),
                        void (this.getLabelByChildName(this.adBtn, "font").string =
                            this.otherinfo.lockNum + "/" + this.config.lock_num)
                    );
                this.currentSnakeDeco ? (this.decoratedBtn.active = !0) : (this.usedBtn.active = !0);
            }),
            (t.prototype.getLabelByChildName = function (e, t) {
                return e.getChildByName(t).getComponent(cc.Label);
            }),
            (t.prototype.addEvent = function () {
                this.node.on(game.EngineEventType.NodeEvent.click, this.clickNodeItem, this);
            }),
            (t.prototype.clickNodeItem = function () {
                var e = this;
                game.AudioManager.playBtnEffect(),
                    this.otherinfo.isUnlock
                        ? game.appFacade.sendNotification(l.default.DECO_TO_SNAKE, {decoIndex: this.config.index})
                        : ad.adInterface.showRewardedVideo(null, null, function () {
                              e.seeAd();
                          });
            }),
            (t.prototype.seeAd = function () {
                ++this.otherinfo.lockNum,
                    this.otherinfo.lockNum >= this.config.lock_num &&
                        ((this.otherinfo.isUnlock = !0),
                        this.renderItem(),
                        game.appFacade.sendNotification(l.default.CLICK_DECO_AD, {
                            index: this.config.index,
                            isUnlock: this.otherinfo.isUnlock,
                            lockNum: this.otherinfo.lockNum
                        }));
            }),
            r([p(cc.Sprite)], t.prototype, "itemImg", void 0),
            r([p(cc.Label)], t.prototype, "itemName", void 0),
            r([p(cc.Node)], t.prototype, "adBtn", void 0),
            r([p(cc.Node)], t.prototype, "usedBtn", void 0),
            r([p(cc.Node)], t.prototype, "decoratedBtn", void 0),
            r([u], t)
        );
    })(cc.Component);
i.default = h;
